package com.geek.javase.wcy02;

/**
 * @author wangchaoyang
 * @desc TODO
 * @date 2025/9/2
 */
import java.util.Scanner;

public class ForDemo2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入金字塔的行数n：");
        int n = scanner.nextInt();

        // 外层循环控制行数
        for (int i = 1; i <= n; i++) {
            // 打印每行前面的空格：数量为 n - i
            for (int j = 1; j <= n - i; j++) {
                System.out.print(" ");
            }
            // 打印每行的星号：数量为 2*i - 1
            for (int k = 1; k <= 2 * i - 1; k++) {
                System.out.print("*");
            }
            // 每行结束后换行
            System.out.println();
        }
    }
}
